# index蓝图的视图
from flask import request, jsonify
from flask_login import login_required

from application.libs.send_msg import email_send_html
from . import mock


@mock.route('/menu')
@login_required
def menu():
    data = {"code": 1001, "menu": {"\u8d44\u6e90\u7ba1\u7406": {"\u6d4b\u8bd5\u8bbe\u5907": "1/resources/device",
                                                                "\u6392\u671f": "/resources/scheduling",
                                                                "\u5361\u8f66\u4e4b\u5bb6\u4e1a\u52a1\u4fe1\u606f\u8868": "/resources/project_information",
                                                                "TestCase": "/resources/testcase",
                                                                "\u8ba1\u5212\u4efb\u52a1": "/resources/add_task"},
                                   "\u8d28\u91cf\u7ba1\u7406": {
                                       "\u8d28\u91cf\u6570\u636e\u6807\u51c6": "/quality/quality",
                                       "bug\u7edf\u8ba1": "/quality/bug_statistics",
                                       "bug\u7387\u8ba1\u7b97": "/quality/bug_calculate",
                                       "bug\u7387\u7edf\u8ba1": "/quality/calculate",
                                       "\u9879\u76ee\u7edf\u8ba1\uff08\u5468\uff09": "/quality/procount"},
                                   "\u6d4b\u8bd5\u5de5\u5177": {"YApi": "/yapi",
                                                                "\u54cd\u5e94\u65f6\u95f4\u6d4b\u8bd5": "/time_test",
                                                                "Arachni": "/test_tools/arachni"},
                                   "\u63a5\u53e3\u76d1\u63a7": {"\u4efb\u52a1\u7ba1\u7406": "/monitor/task_list",
                                                                "\u76d1\u63a7\u7ed3\u679c": "/monitor/result"},
                                   "\u5b9e\u7528\u5de5\u5177": {"\u5468\u62a5\u5de5\u5177": "/weekly_index"},
                                   "\u6301\u7eed\u96c6\u6210": {"\u4efb\u52a1\u7ba1\u7406": "/ci/",
                                                                "\u81ea\u52a8\u5316\u62a5\u544a": "/ci/appreport"}}}
    return jsonify(data)


# @mock.route('/user/login', methods=['post'])
# def login():
#     return jsonify({"code": 20000, "data": {"token": "admin-token"}})


@mock.route('/user/jinyue', methods=['get'])
def jin_yue():
    return jsonify({"code": 20000, "data": "沙子"})


@mock.route('/user/info', methods=['get'])
def info():
    return jsonify({"code": 20000, "data": {"roles": ["admin"], "introduction": "I am a super administrator",
                                            "avatar": "http://localhost:8080/static/img/xiaoyu1.8412bb60.jpg",
                                            "name": "Super Admin"}})


@mock.route('/test', methods=['get'])
def tt():
    return jsonify({"code": 20000, "data": {"token": "admin-token"}})


@mock.route('/query_report')
def queryreport():
    data = {"code": 20000,
            "data": [
                {
                    "color": "#67C23A",
                    "counter": [
                        {"date": "2020-09-22 ", "value": "10"},
                        {"date": "2020-09-24 ", "value": "20"},
                        {"date": "2020-09-25 ", "value": "30"},
                        {"date": "2020-09-26 ", "value": "70"},
                        {"date": "2020-09-30 ", "value": "60"}
                    ],
                    "name": "成功",
                    "type": "bar"
                },
                # {
                #     "color": "#F56C6C",
                #     "counter": [
                #         {"date": "2020-09-22 ", "value": "29"},
                #         {"date": "2020-09-24 ", "value": "29"},
                #         {"date": "2020-09-25 ", "value": "29"},
                #         {"date": "2020-09-26 ", "value": "29"},
                #         {"date": "2020-09-30 ", "value": "0"}
                #     ],
                #     "name": "失败",
                #     "type": "bar"
                # },
                # {
                #     "color": "#3642e6",
                #     "counter": [
                #         {"date": "2020-09-22 ", "value": "0.0333"},
                #         {"date": "2020-09-24 ", "value": "0.0333"},
                #         {"date": "2020-09-25 ", "value": "0.0333"},
                #         {"date": "2020-09-26 ", "value": "0.0333"},
                #         {"date": "2020-09-30 ", "value": "1.0000"}
                #     ],
                #     "name": "成功率",
                #     "type": "line"
                # }
            ]
            }
    return jsonify(data)


@mock.route('/get_total')
def get_total():
    data = {
        "code": 20000,
        "data": {
            "Android极速版": [
                {"name": "成功", "value": "0"},
                {"name": "失败", "value": "0"},
            ],
            "Android标准版": [
                {"name": "成功", "value": "66"},
                {"name": "失败", "value": "130"},
                {"name": "错误", "value": "None"}
            ],
            "iOS极速版": [
                {"name": "成功", "value": "66"},
                {"name": "失败", "value": "130"},
                {"name": "错误", "value": "None"}],
            "iOS标准版": [
                {"name": "成功", "value": "66"},
                {"name": "失败", "value": "130"},
                {"name": "错误", "value": "None"}]
        }
    }
    return jsonify(data)


@mock.route('/testhtml', methods=['get'])
def html():
    # return render_template('pro.html')
    return jsonify({"code": 20000, "data": "沙子"})


@mock.route('/user/testpost', methods=['post'])
def post():
    if request.method == 'POST':
        try:
            req = str(request.get_data())
            # req += "返回个成功"
            # print(request.get_data())
            return jsonify({"code": 20000, "state": "1", "ms": str(req)})
        except Exception as e:
            ret = {"state": "0", "ms": str(e)}

    return jsonify(ret)


@mock.route('/testpost', methods=['post'])
def post1():
    if request.method == 'POST':
        try:
            req = request.form.get("aaa")
            print(req)
            # req = str(request.get_data())
            req += "返回个成功"
            # req = (type(req))
            return jsonify(req)
        except Exception as e:
            ret = {"state": "0", "ms": str(e)}
    return jsonify(ret)


@mock.route('/tabledata', methods=['get'])
def tabledata():
    return jsonify({"code": 20000, "data": {"total": 100, "items": [
        {"id": 1, "timestamp": 824905154426, "author": "James", "reviewer": "Matthew",
         "title": "Awgltumht Eyysnh Atxellxn Rqhpdbdu Rjimpmr", "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://domain/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 65.12, "importance": 2, "type": "US", "status": "published", "display_time": "1989-01-19 23:06:05",
         "comment_disabled": True, "pageviews": 3503,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 2, "timestamp": 83124423052, "author": "Ronald", "reviewer": "Matthew",
         "title": "Dklm Wxiqrhckc Sjubishh Xhtqqw Nqbnegek Gzdr Kzhik Owyryaogy", "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 39.65, "importance": 1, "type": "US", "status": "published", "display_time": "1983-01-15 19:30:02",
         "comment_disabled": True, "pageviews": 1079,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 3, "timestamp": 1266520997601, "author": "Charles", "reviewer": "Jessica",
         "title": "Qygoou Wqrpjkz Stb Uvof Nhnqscv Ztpu Ihmm", "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 63.97, "importance": 1, "type": "CN", "status": "published", "display_time": "1971-07-29 19:12:28",
         "comment_disabled": True, "pageviews": 4989,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 4, "timestamp": 435467567070, "author": "Steven", "reviewer": "Sharon",
         "title": "Uuqxvmnm Ewtdle Pbjoikr Yxayhwyf Ljbvsghh Byddmli Dklgo Coqyj Cysut", "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 59.08, "importance": 2, "type": "US", "status": "published", "display_time": "1976-09-04 05:40:18",
         "comment_disabled": True, "pageviews": 4319,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 5, "timestamp": 172373853786, "author": "Maria", "reviewer": "Lisa",
         "title": "Fkjdkqzf Pnfqx Wly Ynwrhktcio Ldnbeur Skgl Ituukjaq Vuvsxmhg Allswntby Thmgfpv",
         "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 88.12, "importance": 3, "type": "US", "status": "draft", "display_time": "1994-05-11 01:30:20",
         "comment_disabled": True, "pageviews": 4218,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 6, "timestamp": 706187933814, "author": "Sharon", "reviewer": "Melissa",
         "title": "Eybsiavg Qkwt Ysyhwvrwg Erhxrcjxl Nqrrgum Yylyu Suysxpepfe Dsshumj Icvd Grcen",
         "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 52.49, "importance": 1, "type": "US", "status": "draft", "display_time": "1982-12-15 21:12:17",
         "comment_disabled": True, "pageviews": 4428,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 7, "timestamp": 952156443498, "author": "Margaret", "reviewer": "Jose",
         "title": "Plcdvtkw Hudgv Qbjtj Ytketsbo Fiyrmkwnk", "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 78.38, "importance": 1, "type": "US", "status": "published", "display_time": "2016-07-14 08:11:52",
         "comment_disabled": True, "pageviews": 3244,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 8, "timestamp": 175314291832, "author": "Mark", "reviewer": "Eric",
         "title": "Yhhevttc Bqr Qcli Tmsxdhvs Rtkl Kwjspctlb Krw", "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 45.66, "importance": 3, "type": "CN", "status": "draft", "display_time": "1990-06-12 00:02:44",
         "comment_disabled": True, "pageviews": 2329,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 9, "timestamp": 1075582196088, "author": "Lisa", "reviewer": "Jeffrey",
         "title": "Uudvyv Lvvm Lycgmcr Ibfpt Ufbgvixxsk Jxun Ivyeldt Zwxhhfxm", "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 13.33, "importance": 2, "type": "JP", "status": "published", "display_time": "2010-03-23 02:42:48",
         "comment_disabled": True, "pageviews": 4582,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 10, "timestamp": 716819681837, "author": "Michelle", "reviewer": "Daniel",
         "title": "Tcmvvrpefr Gwuegqtgax Qdcnfakir Pfyy Idiwinf Jdptmujsit Qwz Zkmgyvwuk", "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 18.67, "importance": 2, "type": "US", "status": "draft", "display_time": "1981-10-02 01:11:13",
         "comment_disabled": True, "pageviews": 743,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 11, "timestamp": 505955307537, "author": "George", "reviewer": "Kenneth",
         "title": "Wjdciqrh Ycnhr Wwjckgfyn Qhzfri Vslnu Mxkkx Woxmzla Hgjtdxs Ctjj", "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 78.57, "importance": 2, "type": "CN", "status": "draft", "display_time": "1991-05-01 22:09:45",
         "comment_disabled": True, "pageviews": 344,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 12, "timestamp": 1174751750858, "author": "Jason", "reviewer": "Gary",
         "title": "Iqsbjrzrzk Swg Dtgdvbj Pgyxu Ffcpy Bwvdt Otvr Kdbi Plusmmc", "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 3.83, "importance": 2, "type": "CN", "status": "draft", "display_time": "1980-05-05 15:24:19",
         "comment_disabled": True, "pageviews": 4685,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 13, "timestamp": 1325037758144, "author": "Donald", "reviewer": "Melissa",
         "title": "Wjwv Pyqwlrwkpo Jfeuaqjvq Mycwgb Dsjgdgk", "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 97.84, "importance": 2, "type": "CN", "status": "published", "display_time": "2002-12-06 20:48:17",
         "comment_disabled": True, "pageviews": 2357,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 14, "timestamp": 1510074478525, "author": "Jeffrey", "reviewer": "Barbara",
         "title": "Ifusxlxr Npcrbl Lymzrsrk Knnmpp Vorqhtk Qdbp Wqnvjam Wnqqpycriy Xgqnty",
         "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 100.34, "importance": 1, "type": "JP", "status": "draft", "display_time": "2008-03-20 03:54:59",
         "comment_disabled": True, "pageviews": 1878,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 15, "timestamp": 579388769811, "author": "Charles", "reviewer": "David",
         "title": "Yfrrgy Yhsl Vbu Vnfwlhl Nkkvrtks Gisrou Dawbz", "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 68.54, "importance": 1, "type": "US", "status": "draft", "display_time": "1985-01-18 04:42:02",
         "comment_disabled": True, "pageviews": 2818,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 16, "timestamp": 1283656124172, "author": "Margaret", "reviewer": "Matthew",
         "title": "Cscmcorcyr Ututzmowr Llwbnykbql Oqsicvcmkc Dmdk Xwvuopww", "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 77.61, "importance": 1, "type": "US", "status": "draft", "display_time": "2018-11-12 12:30:04",
         "comment_disabled": True, "pageviews": 2736,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 17, "timestamp": 783159838302, "author": "Kenneth", "reviewer": "John",
         "title": "Ipgbtclv Ptxwq Vidwolew Qyxj Nqmqjy Xjceymhof Wqubh Pvbcmxau Ypychbijr",
         "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 60.18, "importance": 2, "type": "US", "status": "draft", "display_time": "1994-09-23 22:20:19",
         "comment_disabled": True, "pageviews": 3408,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 18, "timestamp": 1590849039204, "author": "Patricia", "reviewer": "Ronald",
         "title": "Vonrkv Trmr Tdaukovt Mtpuvscxs Zjmn Uiyhc", "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 53.21, "importance": 1, "type": "JP", "status": "draft", "display_time": "1984-06-07 22:45:19",
         "comment_disabled": True, "pageviews": 4134,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 19, "timestamp": 1127290655966, "author": "George", "reviewer": "Kenneth",
         "title": "Vwurorsj Xfyluxrbuw Ytfsfktpd Sqekpstxf Huqt Yxrwrp Tsmjgr", "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 52.98, "importance": 2, "type": "CN", "status": "draft", "display_time": "1992-03-06 01:01:14",
         "comment_disabled": True, "pageviews": 1674,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3", "platforms": ["a-platform"]},
        {"id": 20, "timestamp": 1205958865301, "author": "Ronald", "reviewer": "Michelle",
         "title": "Cqepmgsxx Edqcbg Klpthr Pjuzmvcch Pnsooqgbv Brdxbfzk Vkfhj Ucpfkimjw Xudq",
         "content_short": "mock data",
         "content": "<p>I am testing data, I am testing data.</p><p><img src=\"https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943\"></p>",
         "forecast": 13.72, "importance": 3, "type": "US", "status": "published", "display_time": "1996-10-27 10:37:23",
         "comment_disabled": True, "pageviews": 1858,
         "image_uri": "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3",
         "platforms": ["a-platform"]}]}})

@mock.route('/bug_calcu_day', methods=['get'])
def bug_calcu_day():
    data={
  "code": 20000,
  "data": [
    {
      "color": "#67C23A",
      "counter": [
        {
          "date": "11-12",
          "value": 3
        },
        {
          "date": "11-14",
          "value": 4
        },
        {
          "date": "11-15",
          "value": 1
        },
        {
          "date": "11-16",
          "value": 2
        },
        {
          "date": "11-17",
          "value": 24
        },
        {
          "date": "11-18",
          "value": 12
        },
        {
          "date": "11-19",
          "value": 1
        },
        {
          "date": "11-25",
          "value": 5
        },
        {
          "date": "11-26",
          "value": 100
        }
      ],
      "name": "引入率",
      "type": "line"
    },{
      "color": "#67C23A",
      "counter": [
        {
          "date": "11-12",
          "value": 3
        },
        {
          "date": "11-14",
          "value": 4
        },
        {
          "date": "11-15",
          "value": 1
        },
        {
          "date": "11-16",
          "value": 2
        },
        {
          "date": "11-17",
          "value": 24
        },
        {
          "date": "11-18",
          "value": 12
        },
        {
          "date": "11-19",
          "value": 1
        },
        {
          "date": "11-25",
          "value": 5
        },
        {
          "date": "11-26",
          "value": 100
        }
      ],
      "name": "引入率",
      "type": "line"
    },
      {
          "color": "#67C23A",
          "counter": [
              {
                  "date": "11-12",
                  "value": 3
              },
              {
                  "date": "11-14",
                  "value": 4
              },
              {
                  "date": "11-15",
                  "value": 1
              },
              {
                  "date": "11-16",
                  "value": 2
              },
              {
                  "date": "11-17",
                  "value": 21
              },
              {
                  "date": "11-18",
                  "value": 12
              },
              {
                  "date": "11-19",
                  "value": 1
              },
              {
                  "date": "11-25",
                  "value": 5
              },
              {
                  "date": "11-26",
                  "value": 1
              }
          ],
          "name": "bug率",
          "type": "line"
      }
  ],
  "message": ""
}
    return jsonify(data)

from ...libs import const
from ...libs.framework import *
@mock.route('/get_project_list', methods=['post'])
def get_project_list():
    res = {
        "items": [
            {
                "group_name": "互动",
                "relation" : True, #关联状态
                "project_name": "Android 融合版",
                "version": "v7.6.0",
                "demand_type": 4,
                "status": 1,
                "end_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                "online_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                "pro_id": 1,
                "bug_rate": "100%",
                "fix_rate": "100%",
                "unfix_rate": "100%",
                "online_rate": "100%",
                "bug_sum": "65",
            },
            {
                "group_name": "互动",
                "relation": True,
                "project_name": "Android 融合版",
                "version": "v7.6.0",
                "demand_type": 2,
                "status": 1,
                "end_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                "online_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                "pro_id": 331,
                "bug_rate": "100%",
                "fix_rate": "100%",
                "unfix_rate": "100%",
                "online_rate": "100%",
                "bug_sum": "65",
            },
            {
                "group_name": "互动",
                "project_name": "Android 融合版",
                "version": "v7.6.0",
                "demand_type": 1,
                "status": 3,
                "relation": True,
                "end_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                "online_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                "pro_id": 11,
                "bug_rate": "100%",
                "fix_rate": "100%",
                "unfix_rate": "100%",
                "online_rate": "100%",
                "bug_sum": "65",
            },
            {
                "group_name": "互动",
                "project_name": "Android 融合版",
                "version": "v7.6.0",
                "demand_type": 4,
                "status": 1,
                "relation": True,
                "end_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                "online_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                "pro_id": 12,
                "bug_rate": "100%",
                "fix_rate": "100%",
                "unfix_rate": "100%",
                "online_rate": "100%",
                "bug_sum": "65",
            },
            {
                "group_name": "互动",
                "project_name": "Android 融合版",
                "version": "v7.6.0",
                "demand_type": 5,
                "status": 1,
                "end_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                "online_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                "pro_id": 12,
                "bug_rate": "100%",
                "fix_rate": "100%",
                "unfix_rate": "100%",
                "online_rate": "100%",
                "bug_sum": "65",
            }
        ],
        "total": 5
    }
    print(">>>>>>>>>>>>>>", request.data)
    if request.json['group_name'] == '2':
        res = {
            "items": [
                {
                    "group_name": "互动",
                    "relation": True,  # 关联状态
                    "project_name": "Android 融合版",
                    "version": "v7.6.0",
                    "demand_type": 4,
                    "status": 1,
                    "end_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                    "online_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                    "pro_id": 1,
                    "bug_rate": "100%",
                    "fix_rate": "100%",
                    "unfix_rate": "100%",
                    "online_rate": "100%",
                    "bug_sum": "65",
                },
                {
                    "group_name": "互动",
                    "project_name": "Android 融合版",
                    "version": "v7.6.0",
                    "demand_type": 1,
                    "status": 3,
                    "relation": True,
                    "end_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                    "online_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                    "pro_id": 11,
                    "bug_rate": "100%",
                    "fix_rate": "100%",
                    "unfix_rate": "100%",
                    "online_rate": "100%",
                    "bug_sum": "65",
                },
                {
                    "group_name": "互动",
                    "project_name": "Android 融合版",
                    "version": "v7.6.0",
                    "demand_type": 4,
                    "status": 1,
                    "relation": True,
                    "end_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                    "online_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                    "pro_id": 12,
                    "bug_rate": "100%",
                    "fix_rate": "100%",
                    "unfix_rate": "100%",
                    "online_rate": "100%",
                    "bug_sum": "65",
                },
                {
                    "group_name": "互动",
                    "project_name": "Android 融合版",
                    "version": "v7.6.0",
                    "demand_type": 5,
                    "status": 1,
                    "end_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                    "online_time": "Wed, 25 Nov 2020 15:38:12 GMT",
                    "pro_id": 12,
                    "bug_rate": "100%",
                    "fix_rate": "100%",
                    "unfix_rate": "100%",
                    "online_rate": "100%",
                    "bug_sum": "65",
                }
            ],
            "total": 4
        }
    
    return result(const.SUCCESS, const.QUERY_SUCCESS, res)


@mock.route('/add_project', methods=['post'])
def add_project():
    res = request.json
    return result(const.SUCCESS, const.QUERY_SUCCESS, res)


@mock.route('/get_project/<project_id>', methods=['get'])
def get_project(project_id):
    res = {'project_id' : project_id}
    relation = True
    pro_data = {
        'v_group': "电商",
        'v_project': "App-ios",
        'v_version': "v750",
        'm_group':  "电商",
        'm_project': "安卓",
        'm_version': "v740"
    }
    project_info = {
        "demand_type": 5,
        "status": 2,
        "start_time": "Wed, 21 Nov 2020 12:38:12 GMT",
        "end_time": "Wed, 25 Nov 2020 15:38:12 GMT",
        "online_time": "Wed, 29 Nov 2020 16:38:12 GMT",
        "pro_id": project_id,
        "mantis": {'P1' : '10', 'P2' : '20', 'P3' : '30', 'P4' : '41', 'P5' : '100', 'reopen' : '14'},
        "tice": 1,
        "ticeanshi": '1',
        "zhunru": '2',
        "zhunchu": '1',
        "zhunchuanshi": '1',
        "cheack": '199',
        "smoke_bug": '11',
        "frist_bug": '18',
        "aa": '1',
        "bug_Legacy": {"nofix_bug": '10', "sum_bug": '192', "ago": '2'},
        "pm_bug": {"use_bug": '10', "pm_fix": '12'},
        "dev_time": '999',
        "online": {"online_status": True, "onlineanshi": True, "online_count": '4', "back": '0'},
        "fix_rate": "100%",
        "unfix_rate": "100%",
        "online_rate": "100%",
        "bug_sum": "65"
    }
    data = {
        'textarea': '123\n1\n1\n1\n1\n1\n',
        'project_info': project_info,
        'relation': relation,
        'pro_data': pro_data
    }
    return result(const.SUCCESS, const.QUERY_SUCCESS, data)


@mock.route('/get_mantis', methods=['post'])
def get_mantis():
    res = request.data
    return result(const.SUCCESS, const.QUERY_SUCCESS, res)

@mock.route('/del_project', methods=['post'])
def del_project():
    res = request.data
    print(request.json)
    return result(const.SUCCESS, const.QUERY_SUCCESS, res)

@mock.route('/get_allinfo', methods=['post'])
def get_allinfo():
    res = request.json
    print(request.json)
    relation = False
    pro_data = {
        'venvOptions':{
          'v_group': [{"group_id":1,"group_name":"互动"},{"group_id":2,"group_name":"电商"}],
          'v_project': [{"project_id":3, "project_name":"App"},{"project_id":4, "project_name":"App-ios"}],
          'v_version': [{"version_id":99, "version_name":"v740"},{"version_id":8, "version_name":"v750"}]
        },
        'mantisOptions':{
          'm_group': [{"group_id":1,"group_name":"互动"},{"group_id":2,"group_name":"电商"}],
          'm_project': [{"project_id":7, "project_name":"安卓"},{"project_id":8, "project_name":"苹果"}],
          'm_version': [{"version_id":99, "version_name":"v740"},{"version_id":8, "version_name":"v750"}]
        }
    }
    project_info = {
        "group_name": "互动",
        "relation": True,
        "project_name": "Android 融合版",
        "version": "v7.6.0",
        "demand_type": 5,
        "status": 2,
        "start_time": "Wed, 21 Nov 2020 12:38:12 GMT",
        "end_time": "Wed, 25 Nov 2020 15:38:12 GMT",
        "online_time": "Wed, 29 Nov 2020 16:38:12 GMT",
        "pro_id": '123',
        "mantis": {'P1': '10', 'P2': '20', 'P3': '30', 'P4': '41', 'P5': '100', 'reopen': '14'},
        "tice": 1,
        "ticeanshi": '1',
        "zhunru": '2',
        "zhunchu": '1',
        "zhunchuanshi": '1',
        "cheack": '199',
        "smoke_bug": '11',
        "frist_bug": '18',
        "aa": '1',
        "bug_Legacy": {"nofix_bug": '10', "sum_bug": '192', "ago": '2'},
        "pm_bug": {"use_bug": '10', "pm_fix": '12'},
        "dev_time": '999',
        "online": {"online_status": True, "onlineanshi": False, "online_count": '4', "back": '0'},
        "fix_rate": "100%",
        "unfix_rate": "100%",
        "online_rate": "100%",
        "bug_sum": "65"
    }
    
    if res['have_data']['m_version'] != '':
        relation = True
        data = {
            "project_info" : project_info,
            "relation": relation,
            "pro_data": pro_data
        }
    else:
        data = {
            "project_info" : '',
            "relation": relation,
            "pro_data": pro_data
        }
        
    return result(const.SUCCESS, const.QUERY_SUCCESS, data)

# if __name__ == '__main__':
#     receiver_list = []
#     receiver_list.append("meng.li@360che.com")
#     fun(receiver_list)
